package etp.server;

import java.util.List;

import javax.jdo.PersistenceManager;
import etp.client.Codigos;

public final class CodFactory {

	private static Codigos COD;
	
	@SuppressWarnings("unchecked")
	public static Codigos get(){
	
		PersistenceManager pm = PMF.get().getPersistenceManager();
		
		try{
		List<Codigos> lc = (List<Codigos>) 
				pm.newQuery("select from " + Codigos.class.getName()).execute();
		
		if(lc.isEmpty()){
			COD = new Codigos();
			COD.setPk(KFactory.keyC());			
		}
		else
			COD = lc.get(0);
		
		return COD;
		}
		finally{
			pm.close();
		}
		
	}
	
}
